package com.shine.minepressure.ui.chart;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.shine.minepressure.BR;
import com.shine.minepressure.R;
import com.shine.minepressure.app.Constants;
import com.shine.minepressure.base.BaseActivity;
import com.shine.minepressure.databinding.ActivityChartBinding;
import com.shine.minepressure.ui.base.BaseDameViewModel;

public class ChartActivity extends BaseActivity<ActivityChartBinding, BaseDameViewModel> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_chart;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public BaseDameViewModel initViewModel() {
        return new BaseDameViewModel(this);
    }

    @Override
    public int appTheme() {
        return Constants.THEME_FULL;
    }

    @Override
    public void initData() {
        super.initData();
        setStatusBar();

        ImageView back = (ImageView) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openOptionsMenu();
            }
        });


        switch (getIntent().getIntExtra("KEY", 0)) {
            case 0:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new LineChartFragment()).commit();
                break;
            case 1:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new ColumnChartFragment()).commit();
                break;
            case 2:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PieChartFragment()).commit();
                break;
            case 3:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new BubbleChartFragment()).commit();
                break;
            case 4:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PreviewLineChartFragment()).commit();
                break;
            case 5:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PreviewColumnChartFragment()).commit();
                break;
            case 6:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new ComboLineColumnChartFragment()).commit();
                break;
            case 7:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new LineColumnDependencyFragment()).commit();
                break;
            case 8:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new TempoChartFragment()).commit();
                break;
            case 9:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new SpeedChartFragment()).commit();
                break;
            case 10:
                getSupportFragmentManager().beginTransaction().add(R.id.container, new GoodBadChartFragment()).commit();
                break;
            case 11:
                switchActivity(ViewPagerChartsActivity.class);
                break;
            default:
                break;
        }


    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            default:
                break;
        }
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                default:
                    break;
            }
        }
    }
}
